package com.qf.test1;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import java.util.stream.Collectors;
import java.util.stream.Stream;

public class MainTest {
	public static void main(String[] args) {
		
		List<Employee> arrList =new ArrayList<Employee>();
		
		arrList.add(new Employee("张明",3000));
		arrList.add(new Employee("徐红",4000));
		arrList.add(new Employee("李张",3500));
		arrList.add(new Employee("王青",5000));
		arrList.add(new Employee("小蓝",6500));
		
		double avgSalary=0;
		
		for (Employee employee : arrList) {
			
			avgSalary+=employee.getSalary();
			
		}
		double res = avgSalary/arrList.size();
		//1.
		System.out.println(res);
		
		Scanner sc = new Scanner(System.in);
		
		String str = sc.next();
		//2.
		//System.out.println(arrList.contains(str));
		for (Employee employee : arrList) {
		if(employee.getName().contains(str)) {
			System.out.println(employee);
			}
		}
		
		
		//3.
		Stream<Employee> stream = arrList.stream();
		List<String> result = stream.sorted((emp1,emp2)->emp2.getSalary()-(emp1.getSalary())).limit(3).map(Employee::getName).collect(Collectors.toList());
		System.out.println(result);
		
	}

}
